#!/usr/bin/python
# -*- coding: utf-8 -*-
"""test tokyotyrant"""

from hashlib import md5
import time

import memcache

caches = [memcache.Client(["10.20.238.173:11212"]), memcache.Client(["10.20.238.173:11211"])]

for cache in caches:
    print cache.get_stats()
    start = time.time()
    num = 100000
    for i in xrange(num):
        v = md5(str(i)).hexdigest()
        cache.set(str(i), `[i, v]`)
    print '%d set %s' % (num, time.time() - start)
    
    start = time.time()
    for i in xrange(num):
        v = md5(str(i)).hexdigest()
        wv = cache.get(str(i))
        assert `[i, v]` == wv, wv
    print '%d get %s' % (num, time.time() - start)
        
    print cache.get_stats()
